Potential fix for code scanning alert no. 1: Clear-text logging of sensitive information#179
Merged
tmcallaghan merged 1 commit intomasterfrom Dec 30, 2025
Merged
Potential fix for code scanning alert no. 1: Clear-text logging of sensitive information#179tmcallaghan merged 1 commit intomasterfrom
tmcallaghan merged 1 commit intomasterfrom
Conversation
…nsitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/awslabs/amazon-documentdb-tools/security/code-scanning/1
In general, the fix is to avoid logging secrets or other sensitive values, especially those retrieved from secret stores. You can still log non-sensitive context (like the cluster name or that a secret was fetched) without including the secret value itself. If some visibility is required for debugging, a safe alternative is to log a redacted or hashed version, or to enable more detailed secret logging only in tightly controlled debug environments—though even that should be done carefully.
For this specific code, the minimal and safest change is to modify
get_cluster_connection_stringso that it no longer logs the actualconnection_string. Line 128 currently logs both the cluster name and the full connection string. We should keep the informative part (that the secret was fetched for the given cluster) but remove the secret from the message. For example, change:to:
No new imports or helper methods are required. This change is fully backward compatible with functional behavior (no effect on business logic), only reducing the amount of sensitive data written to logs. It will also address all alert variants pointing to this logging statement, since they all stem from the same sink.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.